package hadoop;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.mortbay.io.Connection;

import java.io.IOException;
import java.net.URI;

/**
 * @author Chang
 * @date 2021/11/29 16:20
 */
//工具类
public class hadoopUtil {

    public String UpLoad(String srcPath, String destPath) throws IOException {
        String url = ""; //9000端口网站
        Configuration conf = new Configuration();
        FileSystem fileSystem = FileSystem.get(URI.create(url), conf);
        //    上传文件
        Path src = new Path(srcPath); //本地路径
        Path dest = new Path(destPath); //hdfs路径
        fileSystem.copyFromLocalFile(src, dest); //均由前端上传

        return "文件上传成功" ;
    }

}
